package com.learn.mybatis;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * @author MI
 */
public class OnJackCondition implements Condition {


    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {

        return validCondition(context);
    }

    private boolean validCondition(ConditionContext context) {
        Environment environment = context.getEnvironment();
        String value = environment.getProperty("age");

        if (value != null && value.equals("17")) {
            return true;
        }
        return false;
    }

}
